\name{rpoispp3m}
\alias{rpoispp3m}
\title{
  Generate Marked Poisson Point Pattern in Three Dimensions
}
\description{
  Generate a random three-dimensional marked point pattern
  using the homogeneous Poisson process with randomized marks.
}
\usage{
rpoispp3m(lambda, marks, domain = box3(), nsim=1, drop=TRUE)
}
\arguments{
  \item{lambda}{
    Intensity of the Poisson process.
    A single positive number.
  }
  \item{marks}{
    Data frame or matrix containing the marks to be randomly assigned
    to the points. Each row represents one possible mark value.
  }
  \item{domain}{
    Three-dimensional box in which the process should be generated.
    An object of class \code{"box3"}.
  }
  \item{nsim}{Number of simulated realisations to be generated.}
  \item{drop}{
    Logical. If \code{nsim=1} and \code{drop=TRUE} (the default), the
    result will be a point pattern, rather than a list
    containing a point pattern.
  }
}
\value{
  If \code{nsim = 1} and \code{drop=TRUE}, a marked point pattern in
  three dimensions (an object of class \code{"pp3"}).
  If \code{nsim > 1}, a list of such marked point patterns.
}
\details{
  This function generates a realisation
  of the homogeneous Poisson process in three dimensions,
  with intensity \code{lambda} (points per unit volume),
  and assigns marks randomly to each point.

  The marks are assigned by sampling with replacement from the
  provided \code{marks} data frame. Each point in the pattern
  receives a mark vector sampled independently from the rows of
  \code{marks}.

  The realisation is generated inside the three-dimensional region
  \code{domain} which currently must be a rectangular box (object of
  class \code{"box3"}).
}
\note{
  The intensity \code{lambda} is the expected number of points
  \emph{per unit volume}.

  The marks are assigned independently of the point locations,
  following the principle of random labeling.
}
\seealso{
  \code{\link{rpoispp3}},
  \code{\link[spatstat.geom]{pp3}},
  \code{\link[spatstat.geom]{box3}},
  \code{\link{rlabel}}
}
\examples{
   # Create sample marks
   sample_marks <- data.frame(
     type = c('A', 'B', 'C', 'D'),
     size = c(1.0, 2.5, 1.8, 3.2),
     color = c('red', 'blue', 'green', 'yellow')
   )

   # Generate a marked 3D Poisson point pattern
   X <- rpoispp3m(lambda = 10, marks = sample_marks)

   # Generate multiple simulations
   Xlist <- rpoispp3m(lambda = 10, marks = sample_marks, nsim = 3)
}
\author{
  \adrian
  and \rolf.
}
\keyword{spatial}
\keyword{datagen}
\concept{Three-dimensional}
\concept{Marked point pattern}